<script setup lang="ts">
// typescript的相关语法
let flag:boolean = false;
console.log(flag);

let int1:number = 2;
console.log(int1);

let int13:number = 2.33;
console.log(int13);

let str:string = "张菲菲"
str = "zhang"
console.log(str);

let fixed:11 = 11;        //类型是11，名字是fixed，值是11

let randomName:any = "dd"
randomName = 22;

let arr:number[] = [1,23]
console.log(arr);

let arr2:Array<String> = ['d','dd']

  let a : String | number = 3
  a = "d"

//函数
function method1(x:number,y:string){
  return x+y
}
console.log( method1(1,"a"));

function method2(x:number,y:number,z ?:number):number{
  return x+y
}

method2(1,2,3)

//接口限制对象
interface Person{
  id:number,
  name:String
  sing : ()=> void
}

let poet:Person = {
  id :1,
  name:'libai',
  sing : ()=> {}
}

interface Student extends Person{
  id:number,
  name:String,
  sing : ()=> void,
  dance: ()=>{}
}

//泛型函数
function run<T,R>(a:T,b:T):T{
  return a
}

//泛型接口
interface Response<T>{
  status:number,
  message:String,
  data:T
}

//一种结果集
let res:Response<Person>={
  status:200,
  message:"success",
  data:{
    id:1,
    name:"刘备",
    sing:()=>{}
  }
}





</script>

<template>
  <div>

  </div>
  
</template>

<style scoped>
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
  transition: filter 300ms;
}
.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
